﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Threading;

namespace VDataAdapter
{
    class StockWorker : Worker
    {
        protected VdataCommunicator _sender;

        public StockWorker(ManualResetEvent waitFirstTime)
            : base(waitFirstTime, null)
        {

        }

        protected override void DoWork(object data)
        {
            var top3Prices = (IDictionary<string, PriceLibrary.PriceService.StockBase>)data;
            
            foreach (KeyValuePair<string, PriceLibrary.PriceService.StockBase> p in top3Prices)
            {
                var infoDynamic =
                    (PriceLibrary.PriceService.StockInfoDyns)p.Value;
                
                _sender.SendStock(p.Key, infoDynamic);
            }
        }
    }
}
